package com.atguigu.c_datetimeformatter;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoUnit;

public class Test {
    public static void main(String[] args) {
        //准备字符串时间
        String birthDay = "1991年01月01日 00:00:00";


        LocalDateTime birthDayTime =
                LocalDateTime.parse(birthDay, DateTimeFormatter.ofPattern("yyyy年MM月dd日 HH:mm:ss"));

        //获取现在时间
        LocalDateTime now = LocalDateTime.now();

        //时间间隔方法
        long days = birthDayTime.until(now, ChronoUnit.DAYS);
        System.out.println("days = " + days);
    }
}
